<include file="Public:header"/>
<div class="col-sm-10 widget-container-span" style="width: 100%">
<div class="widget-box transparent">
<div class="widget-header">
<div class="widget-toolbar no-border">
<ul class="nav nav-tabs" id="myTab">
<li class="active"><a data-toggle="tab" href="#home1">基本信息</a></li>
<li><a data-toggle="tab" href="#home2">菜单管理</a></li>
<li><a data-toggle="tab" href="#home3">添加/修改菜单</a></li>
<li><a data-toggle="tab" href="#home4">自定义回复</a></li>
<li><a data-toggle="tab" href="#home5">添加/修改自定义回复</a></li>
</ul>
</div>
</div>

<div class="widget-body">
<div class="widget-main padding-12 no-padding-left no-padding-right">
<div class="tab-content padding-4">
<div id="home1" class="tab-pane in active">
<form class="form-horizontal J_ajaxForm" id="myform" action="__CONTROLLER__/setBaseConfig" method="post">
<div class="tabbable">
<div class="tab-content">
<div class="tab-pane active">
<table cellpadding="2" cellspacing="2" width="100%">
<tbody>
<tr>
<td>公众号:</td>
<td><input type="text" class="input" name="num"
value="{$config.num}" id="name"></td>
</tr>
<tr>
<td>url:</td>

<td style="padding:2px 0px;">{$url}
</td>
</tr>
<tr>
<td>token:</td>

<td><input type="text" class="input" name="token"
id="url_input" value="{$config.token}" autocomplete="off">
</td>
</tr>
<tr>
<td>appid:</td>

<td><input type="text" class="input" name="appid"
id="url_input" value="{$config.appid}" autocomplete="off">
</td>
</tr>
<tr>
<td>appsecret:</td>

<td><input type="text" class="input" name="appsecret"
id="url_input" value="{$config.appsecret}" autocomplete="off">
</td>
</tr>
<tr>
<td>encodingaeskey:</td>

<td><input type="text" class="input" name="encodingaeskey"
id="url_input" value="{$config.encodingaeskey}" autocomplete="off">
</td>
</tr>	

</tbody>
</table>
</div>
</div>
</div>
<div class="form-actions">
<button class="btn btn-primary btn_submit J_ajax_submit_btn"
type="submit">提交</button>
<a class="btn" href="">返回</a>
</div>
</form>
</div>

<div id="home2" class="tab-pane in">
<div class="row">
<div class="col-xs-12">
<div class="table-responsive">
<table id="sample-table-1"
class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th class="center"><label> <input
type="checkbox" class="ace"> <span class="lbl"></span>
</label></th>
<th width="120">显示位置ID</th>
<th width="100">ID</th>
<th>显示名称</th>
<th width="80">类型</th>
<th width="200">URL</th>
<th>点击事件key</th>
<th>media_id</th>
<th>管理操作</th>
</tr>

</thead>

<tbody>

<volist name="menuList" id="menu">
<tr>
<td class="center"><label> <input
type="checkbox" class="ace"> <span class="lbl"></span>
</label></td>
<th width="120">
	<if condition="$menu.pid eq 0 ">处于一级目录<else /> {$menu.pid}</if>
</th>
<th width="100">{$menu.menu_id}</th>
<th>{$menu.name}</th>
<th width="80">
	<if condition="$menu.type eq topMenu ">目录<else /> {$menu.type}</if>
</th>
<th width="200">{$menu.url}</th>
<th>{$menu.key}</th>
<th>{$menu.media_id}</th>
<td><a
href="javascript:void(0);" onclick="reWxmenu(this)"
class="btn btn-white btn-sm">修改</a><a
class="J_ajax_del btn btn-white btn-sm"
href="{:U('Admin/Wechat/delMenu',array('id'=>$menu['menu_id']))}">删除</a></td>
</tr>
</volist>
</tbody>
</table>
<div class="form-actions">
<a
href="{:U('Admin/Wechat/createMenu')}"
class="btn btn-primary btn_submit mr10" type="submit">重新生成菜单</a>
</div>
</div>
</div>
</div>
</div>

<div id="home3" class="tab-pane in">
<form class="form-horizontal J_ajaxForm" id="myform" action="__CONTROLLER__/addMenu" method="post">
<div class="tabbable">
<div class="tab-content">
<div class="tab-pane active">
<table cellpadding="2" cellspacing="2" width="100%">
<tbody>
<tr>
<td width="180">上级:</td>
<td><select name="pid" class="normal_select">
<option value="0">作为一级菜单</option>
<foreach name="topList" item="top">
<option value={$top.menu_id}>{$top.name}</option>
</foreach>
</select></td>
</tr>
<tr>
<td>显示名称:</td>
<td><input type="text" class="input" name="name"
value="" id="name" >
<input type="hidden" class="input" name="menu_id" value="0" id="id" >
</tr>
<tr>
<td>类型:</td>
<td><select name="type">
<option value="topMenu" selected="">作为一级目录显示二级</option>
<option value="view" >超链接</option>
<option value="click">点击事件</option>
<option value="scancode_push">扫码推事件</option>
<option value="scancode_waitmsg">扫码推事件且弹出“消息接收中”提示框</option>
<option value="pic_sysphoto">弹出系统拍照发图</option>
<option value="pic_photo_or_album">弹出拍照或者相册发图</option>
<option value="pic_weixin">弹出微信相册发图器</option>
<option value="location_select">弹出地理位置选择器</option>
</select></td>
</tr>
<tr>
<td>URL</td>

<td><input type="text" class="input" name="url"
id="url_input" value="" autocomplete="off">
</td>
</tr>
<tr>
<td>点击事件key</td>
<td><input type="text" class="input" name="key"></td>
</tr>
<tr>
<td> media_id </td>
<td><input type="text" class="input" name="media_id"></td>
</tr>

</tbody>
</table>
</div>
</div>
</div>
<div class="form-actions">
<button class="btn btn-primary btn_submit J_ajax_submit_btn"
type="submit">提交</button>
<a class="btn" href="">返回</a>
</div>
</form>
</div>

<div id="home4" class="tab-pane in">
<div class="row">
<div class="col-xs-12">
<div class="table-responsive">
<table id="sample-table-1"
class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th class="center"><label> <input
type="checkbox" class="ace"> <span class="lbl"></span>
</label></th>
<th>ID</th>
<th>类型</th>
<th>标题</th>
<th>描述</th>
<th>图片</th>
<th>URL</th>
<th>关键词</th>
<th>操作</th>
</tr>

</thead>

<tbody>
<volist name="message" id="message">
<tr>
<td class="center"><label> <input
type="checkbox" class="ace"> <span class="lbl"></span>
</label></td>
<th>{$message.id}</th>
<th>{$message.type}</th>
<th>{$message.title}</th>
<th>{$message.description}</th>
<th>
<div class="btn-group">
<a class="btn btn-white btn-sm" data-toggle="dropdown">
预览
</a>
<div class="dropdown-menu" role="menu">
<center><img style="padding: 0px 0px 6px 0px;max-width:200px;max-height:200px;" src="__PUBLIC__{$message.savepath}{$message.picurl}"/></center>
</div>
</div>
</th>
<th>{$message.url}</th>
<th>{$message.key}</th>
<td><a
href="javascript:void(0);" onclick="reWxmessage(this)"
class="btn btn-white btn-sm">修改</a><a
class="J_ajax_del btn btn-white btn-sm"
href="{:U('Admin/Weixin/delmessage',array('id'=>$message['id']))}">删除</a></td>
</tr>
</volist>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div id="home5" class="tab-pane in">
<form class="form-horizontal J_ajaxForm" enctype="multipart/form-data" id="myform" action="{:U('Admin/Weixin/addmessage')}" method="post">
<div class="tabbable">
<div class="tab-content">
<div class="tab-pane active">
<table cellpadding="2" cellspacing="2" width="100%">
<tbody>
<tr>
<td width="180">类型:</td>
<td><select name="type" class="normal_select">
<option value="0">图文</option>
<option value="1">文本</option>
</select></td>
</tr>
<tr>
<td>标题:</td>
<td><input type="text" class="input" name="title"
value="" id="name" >
<input type="hidden" class="input" name="message_id"
value="0" ></td>
</tr>
<tr>
<td>描述:</td>
<td><textarea name="description" rows="8" cols="32"></textarea></td>
</tr>
<tr>
<td>图片:</td>
<td><input multiple="multiple" type="file" name="picurl">
<p class="help-block">允许的附件文件类型: jpg,gif,png,jpeg并且图片大小小于200k.</p></td>
</tr>
<tr>
<td>URL</td>

<td><input type="text" class="input" name="url"
 value="" autocomplete="off">
</td>
</tr>
<tr>
<td>关键词</td>
<td><input type="text" class="input" name="key"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="form-actions">
<button class="btn btn-primary btn_submit J_ajax_submit_btn"
type="submit">提交</button>
<a class="btn" href="">返回</a>
</div>
</form>
</div>
</div>
</div>
</div>

<script type="text/javascript">
function reWxmenu(o){
var mediaId = $(o).parent().prev().html();
var key = $(o).parent().prev().prev().html();
var url = $(o).parent().prev().prev().prev().html();
var type = $(o).parent().prev().prev().prev().prev().html();
var name = $(o).parent().prev().prev().prev().prev().prev().html();
var menu_id = $(o).parent().prev().prev().prev().prev().prev().prev().html();
var pid = $(o).parent().prev().prev().prev().prev().prev().prev().prev().html();

$('input[name="name"]').val(name);
$('select[name="type"]').val(type);
$('select[name="pid"]').val(pid);
$('input[name="url"]').val(url);
$('input[name="key"]').val(key);
$('input[name="pid"]').val(pid);
$('input[name="menu_id"]').val(menu_id);
$('input[name="media_id"]').val(mediaId);
$('#myTab li').eq(2).find('a').click();
}
var flag = true;
function reWxmessage(o) {
var key = $(o).parent().prev().html();
var url =  $(o).parent().prev().prev().html();
var picurl = $(o).parent().prev().prev().prev().find("center").html();
var description = $(o).parent().prev().prev().prev().prev().html();
var title = $(o).parent().prev().prev().prev().prev().prev().html();
var type = $(o).parent().prev().prev().prev().prev().prev().prev().html();
var id = $(o).parent().prev().prev().prev().prev().prev().prev().prev().html();

$('input[name="title"]').val(title);
$('select[name="type"]').val(type);
$('input[name="url"]').val(url);
$('input[name="key"]').val(key);
$('input[name="message_id"]').val(id);
$('textarea[name="description"]').val(description);

if (flag) {
$('input[name="picurl"]').parent().append(picurl);
flag = false;
}else{
$('input[name="picurl"]').parent().find("img").remove();
$('input[name="picurl"]').parent().append(picurl);
}

$('#myTab li').eq(4).find('a').click();
}


function init(){
		  $('input[name="key"]').parent().parent().hide();
	  $('input[name="media_id"]').parent().parent().hide();
	  $('input[name="url"]').parent().parent().hide();
	function isTopMenu(){
	var type=$('select[name="type"]').val();
	if(type=="topMenu"){
	  $('input[name="key"]').parent().parent().hide();
	  $('input[name="media_id"]').parent().parent().hide();
	  $('input[name="url"]').parent().parent().hide();
  
	}else{
	 $('input[name="key"]').parent().parent().show();
	  $('input[name="media_id"]').parent().parent().show();
	  $('input[name="url"]').parent().parent().show();
	}

	
	}

 $('select[name="type"]').change(isTopMenu);
}
$(window).ready(init);
</script>
</div>
</div>
<include file="Public:footer"/>